﻿// -----------------------------------------------------------------------
// <copyright file="ViewPathEditor.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Rosieks.VisualStudio.Web.Flow.CustomCode
{
    using System.Drawing.Design;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class ViewPathEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            string selectedValue = ViewHelpers.SelectView();
            if (!string.IsNullOrWhiteSpace(selectedValue))
            {
                value = selectedValue;
            }

            return value;
        }
    }
}
